How to use the designer inside Visual Studio 2019

LLBLGen Pro's designer is fully integrated inside Visual Studio 2019. The LLBLGen Pro installer install the Visual Studio extension (VSIX) in Visual Studio 2019 at install time. If you install Visual Studio 2019 after you install LLBLGen Pro, please run the LLBLGenProVSIXPackage.vsix file from the LLBLGen Pro installation folder to install the Visual Studio extension.

Info

All LLBLGen Pro versions share the same ID for the Visual Studio extension. This means that if you install v4.x and v5.x side-by-side, the last one installed is used inside Visual Studio. If you install v4.x after you've installed v5.x, and you want to use v5.x inside Visual Studio, you have to manually run the LLBLGenProVSIXPackage.vsix file from the LLBLGen Pro v5.x installation folder as the v4.x installer comes with an extension which only recognizes v4.x.

If you uninstall v4.x after you've installed v5.x, the extension will be uninstalled by the v4.x installer. To repair the extension in Visual Studio, manually run the LLBLGenProVSIXPackage.vsix file from the LLBLGen Pro installation folder.

Below is a screenshot with the designer integrated inside Visual Studio.

Overview Visual Studio

The LLBLGen Pro designer integrated in Visual Studio using the Dark theme.

How it works

The Visual Studio 2019 integration is implemented through a Visual Studio extension. This extension plugs the various components of the stand-alone LLBLGen Pro designer into Visual Studio and makes sure menu items, tool windows and toolbars work with the actual LLBLGen Pro designer instance. You can uninstall or disable the Visual Studio extension at any time, it has no effect on the stand-alone designer.

The extension implements an editor which is assigned to the LLBLGen Pro project file extension .llblgenproj. When you open a .llblgenproj file in Visual Studio, it will load the editor implemented by the extension. The editor simply loads the LLBLGen Pro designer and opens the various elements in tool windows inside the Visual Studio IDE.

The integration is implemented as an editor for an item/file type, and as such you should add llblgenproj files to your C#/VB.NET/Website projects, as they're not Visual Studio project types. Each .llblgenproj file which is opened is opened as a tab in the Visual Studio document well. Inside this tab, the area of the LLBLGen Pro designer is displayed which holds all open editor tabs and e.g. the home tab. This way, entity editors and the like for a particular open LLBLGen Pro project are kept together. It also made integration easier as Visual Studio's editors are tied to a file, while open entity editors are editors of a file, but of an object in an object model.

Initially when you start Visual Studio, the LLBLGen Pro menu won't be visible. This is because it's context-aware. When an open .llblgenproj file is active in the Visual Studio IDE, the menu will be visible. The same goes for the toolbars. This is equal to e.g. the XML toolbars/XML menu when  you edit for example a web.config file: they're not visible when you edit a C# code file.

Designer panes as tool windows

The various designer panes/sub windows, like Project Explorer, Catalog Explorer and the Error & Warnings pane, are implemented as Visual Studio tool windows, similar to Solution Explorer. The various tool windows will be opened once and shared among the open .llblgenproj files (see next section)

Multiple projects inside the IDE

You can load multiple LLBLGen Pro project files in Visual Studio and they can stay open side-by-side. Per .llblgenproj file, a new LLBLGen Pro instance is started, isolated from the other instances. However, all toolwindows opened by the LLBLGen Pro extension are shared among all open .llblgenproj files. This means that there's just one LLBLGen Pro Project Explorer tool window open, even if you open, say, four .llblgenproj files. The contents of the various tool windows is tied to the active .llblgenproj editor tab in the document well. Switching between these tabs will switch the contents of the tool windows.

Creating new LLBLGen Pro projects

To create a new LLBLGen Pro project inside Visual Studio, follow the same steps as when you'd want to add a C# class: either (preferred) use the Add New Item... menu option of the Visual Studio project or use File -> New -> File. Both options will offer you an option to select an LLBLGen Pro Project file. In the Add New Item... dialog box, you can find the LLBLGen Pro project file in the 'Data' section.

Creating a new LLBLGen Pro project through Visual Studio will create an empty file on disk and then open the LLBLGen Pro designer as an editor for this file. As the file is empty, it will show the Project Creation dialog which is also shown inside the LLBLGen Pro stand-alone designer when creating a project. You can't change the file location nor cancel this process at this point as it's a step inside a multi-step process inside Visual Studio.

When completing the dialog by clicking OK, the project will be created in the specified llblgenproj file and opened inside the LLBLGen Pro designer loaded inside Visual Studio.

Generating code and auto-loading of generated Visual Studio projects

When you generate code inside Visual Studio, the extension will automatically add all generated Visual Studio projects to the open solution. If they're already added to this solution, it will leave them alone. Visual Studio projects won't be auto-reloaded, simply because Visual Studio doesn't have this feature.

Things to be aware of

You should take the following aspects into account when using the designer inside Visual Studio:

  • The text editor (used for template editing) has as local undo/redo Ctrl-Shift-Z / Ctrl-Shift-Y and the normal undo/redo will be Ctrl-Z / Ctrl-Y. In the stand-alone designer this is reversed.
  • When changing a model aspect in the project explorer and you want to undo this change, you have to click inside the document tab which represents the LLBLGen Pro project in which you want to undo the change, as the undo/redo buttons are owned by the editor associated with the LLBLGen Pro project loaded inside Visual Studio, not the toolwindow.
  • The Project Explorer, Catalog Explorer, Errors & Earnings pane, Feature Hints pane and Application Output Windows are tool windows inside Visual Studio, but these are shared among every open LLBLGen Pro project. This means that they reflect the project which is the (last) active selected LLBLGen Pro project in the document area.
  • The 'Home tab' might consume keyboard shortcuts. If you don't need the quick start guides, close the home tab on startup in the preferences.
  • Import has been disabled in the Visual Studio integration because importers require a separate appdomain and creating a separate appdomain inside a VS extension build with .NET currently crashes. Import is enabled in the stand-alone designer, so if you need to import project elements, load the llblgenproj file into the standalone designer.

Troubleshooting the Visual Studio integration

It might be you run into a problem with the Visual Studio integration of the designer. We did everything we could to make it a seamless and frictionless experience, but as Visual Studio is a complex, non-consistent beast, there might be situations where the Visual Studio extension doesn't behave as expected. Below we have given some information what to do when you run into a particular situation.

  • Double-clicking / opening a .llblgenproj file in Solution Explorer opens it in the stand-alone designer. This occurs when the file extension .llblgenproj inside Visual Studio isn't associated with the LLBLGen Pro Visual Studio extension but instead with 'LLBLGen Pro v5.1'. This is likely caused by the fact the LLBLGen Pro installer was run when Visual Studio was still open. To check and fix this, right-click your llblgenproj file in Solution Explorer, select 'Open with' and select 'LLBLGen Pro designer integrated in Visual Studio' as the default editor. Additionally you can re-run the installer for the Visual Studio extension, which is the file LLBLGenProVSIXPackage.vsix in the LLBLGen Pro installation folder. Double-click it to run it. Make sure no Visual Studio instance is open when the vsix installer runs.
  • After generating code, the extension gives an error when loading the new Visual Studio projects into the solution. This might be caused by the fact you use a type converter in the LLBLGen Pro project which is loaded from the solution itself. This means it's locked, and loading the Visual Studio projects automatically fails. To work around this, place the type converter projects into another solution.

How the Visual Studio extension finds the LLBLGen Pro installation folder

If for some reason the extension doesn't open the LLBLGen Pro designer anymore inside Visual Studio, it might be the registry key which contains the LLBLGen Pro installation folder is no longer present or contains the wrong value. The Visual Studio extension uses the default value of the registry key HKLM\Software\Solutions Design\LLBLGen Pro v5.y (where 'y' is the minor version number of the LLBLGen Pro version you want to load into Visual Studio) for the path to the LLBLGen Pro installation folder. This key is both present in the 32bit and 64bit registry hive. If you move the LLBLGen Pro installation folder without using the installer, please adjust this registry key.

There can be multiple versions of this registry key, one for each LLBLGen Pro v5.x version you have installed. The extension will first search for the latest v5.x version it knows of, and then fall back to older versions it knows of.